package com.yang.springcloud.controller;

import com.alibaba.fastjson.JSONObject;
import com.yang.springcloud.pojo.Member;
import com.yang.springcloud.pojo.Student;
import com.yang.springcloud.service.MemberServiceImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
public class MemberController {

    @Autowired
    private MemberServiceImp msi;

    @PostMapping("/insertInfo")
    public Map<String, Object> insertMemberInfo(@RequestBody String info) {
        System.out.println(info);
        List<Member> m = JSONObject.parseArray(info, Member.class);
        System.out.println(m);
        return msi.insertMemberInfo(m);
    }

    @GetMapping("/queryAll")
    public List<Member> queryMemberAll() {
        return msi.queryMemberAll();
    }

    @GetMapping("/queryById/{passid}")
    public Student queryById(@PathVariable("passid") String passid){
        System.out.println("服务端执行了");
        return msi.queryById(passid);

    }
}
